package com.tanhua.sso.service;

import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;

public class SendSms {

    public static void main(String[] args) throws ClientException {
        DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou",
                "LTAI4G8JnJEtrEtZXJYREP9M", "OxCdfunm86om31jU0KdzUXbpWfvJUC");
        IAcsClient client = new DefaultAcsClient(profile);
        CommonRequest request = new CommonRequest();
        request.setSysMethod(MethodType.POST);
        request.setSysDomain("dysmsapi.aliyuncs.com");
        request.setSysVersion("2017-05-25");
        request.setSysAction("SendSms");
        request.putQueryParameter("RegionId", "cn-hangzhou");
        request.putQueryParameter("PhoneNumbers", "18675590994"); //目标手机号
        request.putQueryParameter("SignName", "传智健康"); //签名名称
        request.putQueryParameter("TemplateCode", "SMS_195226089"); //短信模板code
        request.putQueryParameter("TemplateParam", "{\"code\":\"123456\"}");//模板中变量替换

        CommonResponse response = client.getCommonResponse(request);
        //{"Message":"OK","RequestId":"EC2D4C9A-0EAC-4213-BE45-CE6176E1DF23","BizId":"110903802851113360^0","Code":"OK"}
        //{"RequestId":"A4FDB9D6-25FF-475D-AC3C-B78ED6EDE7AA","Message":"账户余额不足","Code":"isv.AMOUNT_NOT_ENOUGH"}
        System.out.println(response.getData());

    }
}
